<template>
	<view :class="vi_pageSize">
		<vi-notify :top="topfix" ref="vi_notify"></vi-notify>
		<module-loading ref="vi_loading" :loading="vi_loading" :loadingMask="vi_loadingMask"></module-loading>
		<vi-headbar>{{vi_pageTitle}}</vi-headbar>
		<view class="p-sm">
			<view class="py-sm">
				<vi-button @click="sign">打卡</vi-button>
			</view>
			<view class="py-sm">
				<vi-button plain @click="openSign">打卡列表</vi-button>
			</view>
			<view class="py-sm">
				<vi-button plain @click="linkToKey('basic')">基础组件</vi-button>
			</view>
			<view class="py-sm">
				<vi-button plain @click="linkToKey('form')">表单组件</vi-button>
			</view>
			<view class="py-sm">
				<vi-button plain @click="linkToKey('service')">业务组件</vi-button>
			</view>
			<view class="py-sm">
				<vi-button plain @click="linkToKey('compatible')">兼容问题展示</vi-button>
			</view>
			<view class="py-sm">
				<vi-button plain @click="linkToKey('thread')">多线程示例</vi-button>
			</view>
		</view>
		<!-- 打开列表 -->
		<vi-drawer ref="signList" point="right">
			<view class="topFix-statusNavbar">
				<view class="p-md full borderbox">
					<scroll-view class="full" scroll-y>
						<view class="fbox py-md lh-1p8 bb-dashed-default" v-for="(item,index) in dataList">
							<view class="grow fontSize-sm">
								<view class="bold">{{dateFormat(item.time, "YYYY-MM-DD hh:mm:ss")}}</view>
								<view class="color-tips">
									<text class="mr-e1">{{item.device}}</text>
									<text>{{item.system}}</text>
								</view>
							</view>
							<view class="iconfont icon-delete color-error p-sm" @click="delSign(item)"></view>
						</view>
					</scroll-view>
				</view>
			</view>
		</vi-drawer>
		
		<vi-tabbar isTop statusFix appletFix></vi-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList:[],
			}
		},
		methods: {
			sign(){
				let sysInfo = uni.getSystemInfoSync();
				const signFun = uniCloud.importObject("sign");
				let promise = signFun.set(sysInfo);
				promise.then((res)=>{
					this.$api.msg(res.msg)
				})
			},
			getSign(){
				const signFun = uniCloud.importObject("sign");
				let promise = signFun.get();
				promise.then((res)=>{
					this.dataList = res.data ||[];
				})
			},
			delSign(item){
				const signFun = uniCloud.importObject("sign");
				let promise = signFun.del(item._id);
				promise.then((res)=>{
					this.$api.msg(res.msg);
					this.getSign();
				})
			},
			openSign(name){
				this.getSign();
				this.openWin("signList");
			},
		},
		onLoad() {
			
		}
	}
</script>

<style lang="scss" scoped>

</style>
